<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" id="key">
<input id="value" type="text">
<button id="save">111</button>
<button id="read">2222</button>
</body>
<script>
    document.getElementById("save").onclick=function () {
        var k = document.getElementById("key").value;
        var v = document.getElementById("value").value;
        sessionStorage.setItem(k,v);
    };
    document.getElementById("read").onclick=function () {
        var len = sessionStorage.length;
        for (let i = 0; i < len; i++) {
            let  k = sessionStorage.key(i);
            let v = sessionStorage.getItem(k);
            console.log(k+""+v)
        }
    }
</script>
</html>